﻿// ===============================================================================
//  Copyright © ymind.net. All rights reserved .
//  官方网站：http://ymind.net/
//  版权所有：彦铭工作室 老陈出品
// ===============================================================================

using System;
using Lcsoft.RssEngine.Collections;
using Lcsoft.RssEngine.Shared;

namespace Lcsoft.RssEngine.RssItem
{
	/// <summary>A channel may contain any number of items, each of which links to more information about the item, with an optional description</summary>
	[Serializable]
	public class RssItem : IRssElement
	{
		private string _author = String.Empty;
		private string _comments = String.Empty;
		private string _description = String.Empty;
		private Uri _link = RssDefault.UriValue;
		private string _title = String.Empty;

		/// <summary>
		/// 
		/// </summary>
		public RssItem()
		{
			this.Categories = new RssCategoryCollection();
			this.PubDate = RssDefault.DateTimeValue;
		}

		/// <summary>Title of the item</summary>
		/// <remarks>Maximum length is 100 (For RSS 0.91)</remarks>
		public string Title
		{
			get { return this._title; }
			set { this._title = RssDefault.Check(value); }
		}

		/// <summary>URL of the item</summary>
		/// <remarks>Maximum length is 500 (For RSS 0.91)</remarks>
		public Uri Link
		{
			get { return this._link; }
			set { this._link = RssDefault.Check(value); }
		}

		/// <summary>Item synopsis</summary>
		/// <remarks>Maximum length is 500 (For RSS 0.91)</remarks>
		public string Description
		{
			get { return this._description; }
			set { this._description = RssDefault.Check(value); }
		}

		/// <summary>Email address of the author of the item</summary>
		public string Author
		{
			get { return this._author; }
			set { this._author = RssDefault.Check(value); }
		}

		/// <summary>Provide information regarding the location of the subject matter of the channel in a taxonomy</summary>
		public RssCategoryCollection Categories { get; private set; }

		/// <summary>URL of a page for comments relating to the item</summary>
		public string Comments
		{
			get { return this._comments; }
			set { this._comments = RssDefault.Check(value); }
		}

		/// <summary>Describes an items source</summary>
		public RssSource Source { get; set; }

		/// <summary>A reference to an attachment to the item</summary>
		public RssEnclosure Enclosure { get; set; }

		/// <summary>A string that uniquely identifies the item</summary>
		public RssGuid Guid { get; set; }

		/// <summary>Indicates when the item was published</summary>
		public DateTime PubDate { get; set; }

		/// <summary>Returns a string representation of the current Object.</summary>
		/// <returns>The item's title, description, or "RssItem" if the title and description are blank.</returns>
		public override string ToString() { return this._title ?? (this._description ?? "RssItem"); }
	}
}
